Hull City took a huge step forward in their bid to avoid Premier League relegation as Andrea Ranocchia's late header secured a dramatic 2-1 victory over West Ham.